<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu.tld" prefix="menu" %>
<%@ taglib uri="/WEB-INF/tlds/struts-menu-el.tld" prefix="menu-el" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tlds/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tlds/authz.tld" prefix="authz" %>
<%@ taglib uri="/WEB-INF/tlds/sitemesh-decorator.tld" prefix="decorator"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="request"/>
<script type="text/javascript" src="${ctx}/dwr/interface/ResourceServiceDWR.js"></script>
<script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
<script type="text/javascript" src="${ctx}/dwr/util.js"></script>
<script type="text/javascript">
	function modifyId() {
		var idVal=checkValue($('identifiantForm'),'id');
		if(!idVal || idVal.length==0) {
			alert('<bean:message key="info.selectIdentifiant"/>');
		} else {
			popup('identifiant.do?method=edit&decorator=popup&confirm=true&id='+idVal, 'popupId', 450, 400);
		}
	}
	function addId() {
		var completeId=$F("value");
		if(completeId.length>0){
			return false;
		}
		var idVal='';
		popup('identifiant.do?method=edit&decorator=popup&confirm=true&id='+idVal, 'popupId', 450, 400);
	}
	function deleteId() {
		var idVal=checkValue($('identifiantForm'),'id');
		if(idVal==null || idVal.length==0) {
			alert('<bean:message key="info.selectIdentifiant"/>');
		} else if(confirm('<bean:message key="info.confirmDeletion" />')) {
			$('method').value='delete';
			$('identifiantForm').submit();
		}
	}
	
	function validateId() {
		var idVal=$F("value");
		this.opener.document.resourceForm.identifiant.value=idVal;
		closePopup();
	}
</script>
<div id="subcontent">
	<html:form styleId="identifiantForm" action="/identifiant">
		<input type="hidden" id="decorator" name="decorator" value="popup" />
		<input type="hidden" id="confirm" name="confirm" value="true" />
		<input type="hidden" id="method" name="method" value="" />
		<p><bean:message key="identifiantPage.identifiantsList" /></p>
		<p>
			<table class="list" id="idList">
				<thead>
					<tr>
						<th>-</th>
						<th><bean:message key="identifiantPage.name" /></th>
						<th><bean:message key="identifiantPage.value" /></th>
					</tr>
				</thead>
				<tbody>
					<c:forEach var="identifiant" items="${identifiants}">
						<tr>
							<td><input type="radio" name="id" id="id" value="${identifiant.id}" /></td>
							<td><c:out value="${identifiant.name}" /></td>
							<td><c:out value="${identifiant.value}" /></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</p>
		<p>	<input name="addIdButton" type="submit" value="<bean:message key="identifiantPage.add" />" onclick="addId();return false;" />&nbsp;
			<input name="modifyIdButton" type="submit" value="<bean:message key="identifiantPage.modify" />" onclick="modifyId();return false;" />&nbsp;
			<input name="delIdButton" type="submit" value="<bean:message key="identifiantPage.delete" />"	onclick="deleteId();return false;" />
		</p>
		<p><bean:message key="identifiantPage.completeIdentifiant" /></p>
		<p style="font-weight:normal"><bean:write name="identifiantForm" property="identifiant.value"/>  </p>
		<html:hidden name="identifiantForm" property="identifiant.value"  styleId="value"/>
		<p>
			<input name="validateIdButton" type="button" value="<bean:message key="identifiantPage.validate" />" onclick="validateId();return false;" />&nbsp;
			<input name="cancelIdButton" type="button" value="<bean:message key="identifiantPage.cancel" />" onclick="closePopup();" />
		</p>
	</html:form>
</div>